Run windows command (start a Java app.) in DXL.

Hi!

I have a Java application (.jar) and I need to run this from DXL. I used win32SystemWait_ function in DXL. The DXL write some data to a file then need to run the Java application which read and write this file and after that the Java app ended the DXL read the file again to collect the new data. I can write data with DXL but after the win32SystemWait_ command the app return always with 1. I want to give the filename to the Java app in the argument list. The Java app works fine because I tried it from the command-line without DXL code, but if I want to start from DXL than does nothing.

So, the point:

1. Write data to the file with dxl

2. Start a Java application from dxl

3. Read and write the file from the Java app (during this time the dxl wait)

4. After Java app ended read the file with dxl and do something with the new data.

 

The DXL snippet:


...


string result = "";


string filename = "MyFile.txt";  // I know that the full path is necessary


int returnValue = win32SystemWait_("JavaApp.jar "filename, result, -1); // I know that the full path is necessary


...

The returnValue is always 1 but I think it must be 0.

Thanks for help!

 

 

 


dinci11 - Tue Aug 15 07:24:22 EDT 2017

Re: Run windows command (start a Java app.) in DXL.
Mathias Mamsch - Tue Aug 15 08:23:01 EDT 2017

Did you try running the full command? 

java -jar ...

I think a return value of 1 means, that the process could not be started.

try: "java -version" 

to make sure that java is available. So somehow it cannot launch the process. You are not running the DXL in batch mode from a service, are you? :-) 

A sure way to find out is to launch process monitor from sysinternals and track the doors.exe process to find out which files it tries to open and which files are not found!

Regards, Mathias

Re: Run windows command (start a Java app.) in DXL.
dinci11 - Tue Aug 15 08:32:38 EDT 2017

Mathias Mamsch - Tue Aug 15 08:23:01 EDT 2017

Did you try running the full command? 

java -jar ...

I think a return value of 1 means, that the process could not be started.

try: "java -version" 

to make sure that java is available. So somehow it cannot launch the process. You are not running the DXL in batch mode from a service, are you? :-) 

A sure way to find out is to launch process monitor from sysinternals and track the doors.exe process to find out which files it tries to open and which files are not found!

Regards, Mathias

With Java there is no problem because I have tried out my Java app from commandline with " JavaApp.jar MyFile.txt " command. I run my DXL script direct from a Doors module with UI ,so no batch mode I think. (I hope that it was the question what you wanted, I'm new in Doors environment :D )

Re: Run windows command (start a Java app.) in DXL.
Mathias Mamsch - Tue Aug 15 15:54:31 EDT 2017

dinci11 - Tue Aug 15 08:32:38 EDT 2017

With Java there is no problem because I have tried out my Java app from commandline with " JavaApp.jar MyFile.txt " command. I run my DXL script direct from a Doors module with UI ,so no batch mode I think. (I hope that it was the question what you wanted, I'm new in Doors environment :D )

win32SystemWait does not use the shell to start commands so there are differences. I think it will parse the commandline, try to extract the first argument and try to launch it as a process. I am not sure this works for jar files. Compare the following code: 

int returnValue = -5; 

string result = ""; 

result = ""
returnValue = win32SystemWait_("echo hallo", result, -1);
print "Without Shell -> " returnValue "\n" result "\n"  // Does not work! Result -1 

result = ""
// remove the spaces between c m d - the forum won't let me post this code otherwise
returnValue = win32SystemWait_("c m d.exe /C echo hallo", result, -1); // Works! Result 0
print "Shell -> " returnValue "\n" result "\n"

 

So not everything that works from the commandline will work from win32SystemWait_  ... I think the problem is that you need to specify the full command to launch your jar (java -jar ....) , not only the jar itself. Regards, Mathias

Re: Run windows command (start a Java app.) in DXL.
dinci11 - Wed Aug 16 02:50:26 EDT 2017

Mathias Mamsch - Tue Aug 15 15:54:31 EDT 2017

win32SystemWait does not use the shell to start commands so there are differences. I think it will parse the commandline, try to extract the first argument and try to launch it as a process. I am not sure this works for jar files. Compare the following code: 

int returnValue = -5; 

string result = ""; 

result = ""
returnValue = win32SystemWait_("echo hallo", result, -1);
print "Without Shell -> " returnValue "\n" result "\n"  // Does not work! Result -1 

result = ""
// remove the spaces between c m d - the forum won't let me post this code otherwise
returnValue = win32SystemWait_("c m d.exe /C echo hallo", result, -1); // Works! Result 0
print "Shell -> " returnValue "\n" result "\n"

 

So not everything that works from the commandline will work from win32SystemWait_  ... I think the problem is that you need to specify the full command to launch your jar (java -jar ....) , not only the jar itself. Regards, Mathias

It works fine with java -jar... !

Thanks so much